#!/bin/guile \
-e main -s
!#

;; create a random number cool!
(define number (random 100 (random-state-from-platform)))

(define (main args)
  (display "I have a favorite number between 1 and 100.  Your Guess? ")
  (display "\n")
  (display "\n")
  ;; create a named let that loops until you guess the number correctly.
  (let loop ((guess (read)) (number number))
    (cond
     ((< guess number)
      (begin
        (display "Guess higher")
        (display "\n")
        (loop (read) number)))
     ((> guess number)
      (display "Guess lower")
      (display "\n")
      (loop (read) number))
     (else
      (begin
        (display "Correct!")
        (display "\n"))))))
